//
//  NewEditCardCell.m
//  Shengzhuli
//
//  Created by FXGuo on 2018/1/24.
//  Copyright © 2018年 kamangkeji. All rights reserved.
//

#import "NewEditCardCell.h"
#import <UIButton+WebCache.h>

@interface NewEditCardCell()

@property (weak, nonatomic) IBOutlet UIButton *avaBtn;
@property (weak, nonatomic) IBOutlet UITextField *nameField;
@property (weak, nonatomic) IBOutlet UITextField *phoneField;
@property (weak, nonatomic) IBOutlet UITextField *positionField;
@property (weak, nonatomic) IBOutlet UITextField *addressField;
@property (weak, nonatomic) IBOutlet UITextField *personalizedSignatureField;

@end

@implementation NewEditCardCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.avaBtn.layer.borderColor = RGBColorOne(230).CGColor;
    self.avaBtn.layer.borderWidth = 1;
    self.avaBtn.layer.cornerRadius = 5.0;
    self.avaBtn.clipsToBounds = YES;
}

- (void)setInfo:(PersonInfo *)info
{
    _info = info;
    if (info.portraitUrl) {
        [self.avaBtn sd_setBackgroundImageWithURL:[NSURL URLWithString:info.portraitUrl] forState:UIControlStateNormal placeholderImage:GetImage(@"person_avatar")];
    }
    if (info.name) {
        self.nameField.text = info.name;
    }
    if (info.mobilePhone) {
        self.phoneField.text = info.mobilePhone;
    }
    if (info.position) {
        self.positionField.text = info.position;
    }
    if (info.detailedAddress) {
        self.addressField.text = info.detailedAddress;
    }
    if (info.personalizedSignature) {
        self.personalizedSignatureField.text = info.personalizedSignature;
    }
}
- (IBAction)fieldChanged:(UITextField *)field
{
    switch (field.tag) {
        case 0:
        {
            self.editInfo.name = field.text;
        }
            break;
        case 2:
        {
            self.editInfo.position = field.text;
        }
            break;
        case 3:
        {
            self.editInfo.detailedAddress = field.text;
        }
            break;
        case 4:
        {
            self.editInfo.personalizedSignature = field.text;
        }
            break;
            
        default:
            break;
    }
}


- (IBAction)avaClick:(UIButton *)btn
{
    if (self.avaClickBlock) {
        self.avaClickBlock(btn);
    }
}

@end
